<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="/common/taglibs.jsp"%>
<!-- 审批意见 -->
<script type="text/javascript">

	var AuditWindow = new Ext.Window({
		el: 'auditWindow',
	    width: 400,
	    height: 250,
	    layout : 'fit',
	    closeAction:'hide',
	    buttonAlign:'center',
	    modal:'true',
	    buttons:[{
	    	text:'确定',
	        handler:function(){
	          	if (AuditWindow.check()){ 
	      	    	var descn = document.getElementById('descn').value;
	      	    	agreeVal = getAgreeValue();
	      	     	$.ajax({
		    			url: '${ctx}/flow/node/saveAudit.do',
		    			type: 'post',
		    			dataType: 'json',
		    			data: {'model.id' : nId, 'model.status' : agreeVal, 'model.descn': descn},
		    			success: function(rst, textStatus){
		    	  			if(rst.result == "success"){
		    	  				ECSideUtil.reload('ec');
		    	  	  		}else{
		    	  	  			AuditWindow.hide();
		    	  	  			alert("审批失败：" + rst.msg);
		    	  	  	  	}
	    				}
	    	  	 	});
	      	     	AuditWindow.hide();
	             	AuditWindow.clear();
	          	}
	        }
	    }, {
	    	text:'取消',
	        handler:function(){
	        	AuditWindow.hide();
	        	AuditWindow.clear();
	    	}
	    }]
	});

	// 清空
	AuditWindow.clear = function() {
		document.getElementById('descn').value = '';
		document.getElementById('isAgreePass').checked = '';
		document.getElementById('isAgreeNoPass').checked = '';
	};

	// 检测
	AuditWindow.check = function() {
		if (agreeVal == null || agreeVal == '') {
			Ext.MessageBox.show({
				title : '提示',
				minWidth : 220,
				msg : '<div style=\'width:180\';><br/>请选择[<font color="green"><b>同意</b></font>] 或 [<font color="red"><b>不同意</b></font>] </div>',
				buttons : Ext.MessageBox.OK,
				icon : Ext.MessageBox.INFO
			});
			return false;
		}
		return true;
	};

	var nId = null;
	var agreeVal = null;
	var openUrl = null;
	var dialogWidth = null;
	var dialogHeight = null;
	
	function showAuditWindow(nodeId, aValue, descn, url, width, height) {
		nId = nodeId;
		agreeVal = aValue;
		openUrl = url;
		dialogWidth = width;
		dialogHeight = height;
		if (aValue == "nopass"){
			document.getElementById('isAgreePass').checked = '';
			document.getElementById('isAgreeNopass').checked = 'checked';
		}else{
			document.getElementById('isAgreePass').checked = 'checked';
			document.getElementById('isAgreeNoPass').checked = '';
		}
		document.getElementById('descn').value = descn;
		AuditWindow.show();
	}
	
	//获得审批状态
	function getAgreeValue() {
		if (document.getElementById('isAgreePass').checked == true){
			return "pass";
		}
		return "nopass";
	}
	
	//打开详情窗口
	function openDetail(width, height){
		var styles = "dialogWidth:" + dialogWidth + "px; dialogHeight:" + dialogHeight + "px; status:no; scroll:auto; help:no;";
		if(openUrl != null){
			window.showModalDialog(openUrl, null, styles);
		}else{
			Ext.MessageBox.show({
				title : '提示',
				minWidth : 220,
				msg : '<div style=\'width:180\';><br/>未配置详情地址!</div>',
				buttons : Ext.MessageBox.OK,
				icon : Ext.MessageBox.INFO
			});
		}
	}
</script>
</head>
<body>
<!-- 审批 -->
<div id="auditWindow" class="x-hidden">
<div class="x-window-header">审批意见</div>
<div class="x-window-body">
	<table align="center" cellspacing="6">
	  <tr>
	    <td align="right">
	      <span style="color: red;">*</span>是否同意：
	    </td>
	    <td>
	    	<input type="radio" id="isAgreePass" name="isAgree" value="pass" style="border: 0px;" ><font color="green"><b>同意</b></font>&nbsp;&nbsp;
	    	<input type="radio" id="isAgreeNopass" name="isAgree" value="nopass" style="border: 0px;"><font color="red"><b>不同意</b></font>&nbsp;&nbsp;
	    	&nbsp;&nbsp;&nbsp;&nbsp;
	    	<img src="${ctx}/images/icons/zoom.gif"><a href="#" onclick="openDetail()"><b>查看详情</b></a>&nbsp;&nbsp;
        </td>
	  </tr>
	  <tr>
	    <td align="right">
	      &nbsp;审批意见：
	    </td>
		<td align="left">
		  <textarea rows="7" id="descn" style="width:280px; padding: 5px;"></textarea>
	    </td>
	  </tr>
	</table>
</div>
</div>
